/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.gpaltan.db;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 *
 * @author srkrishnan
 */
public class DBManager {

    private Connection conn = null;
    String url = "jdbc:mysql://localhost:3306/";
    String dbName = "s1";
    String driver = "com.mysql.jdbc.Driver";
    String userName = "root";
    String password = "support";

    public DBManager(String url,String dbName,String driver,String userName,String password) {
        this.url=url;
        this.dbName=dbName;
        this.driver=driver;
        this.userName=userName;
        this.password=password;
    }

    
    
    public void connectDB() {

        try {
            Class.forName(driver).newInstance();
            conn = DriverManager.getConnection(url + dbName+"?autoreconnect=true", userName, password);
            System.out.println("Connected to the database "+url+dbName);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public Connection getConnection() {
        return conn;
    }
}
